package org.csu.mybigpro.persistence;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.csu.mybigpro.domain.User;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("""
        SELECT u.* FROM user u
        JOIN user_role ur ON u.id = ur.user_id
        WHERE ur.role_id = 3
    """)
    List<User> selectAllTeachers();

    @Select("SELECT u.* FROM user u " +
            "INNER JOIN user_role ur ON u.id = ur.user_id " +
            "WHERE ur.role_id = 3 AND u.name LIKE CONCAT('%', #{name}, '%')")
    List<User> selectTeachersByName(@Param("name") String name);

}